package animation7.view.xiaomage.com.viewanimation7

import android.animation.ObjectAnimator
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.util.AttributeSet
import android.util.Log
import android.view.View
import java.util.*
import java.util.jar.Attributes

/**
 * Created by Administrator on 2017/12/24.
 */
class MyPointView:View {
    private var point:Point?=null

    constructor(context:Context):super(context)
    constructor(context:Context,attrs:AttributeSet):super(context,attrs )

    override fun onDraw(canvas: Canvas) {
        if(point!=null){
            val paint=Paint()
            paint.isAntiAlias=true
            paint.style=Paint.Style.FILL
            canvas.drawCircle(300f,300f,point!!.radius,paint)
        }
        super.onDraw(canvas)
    }
    public fun doPointViewAnimation(){
        val objectAnimator=ObjectAnimator.ofFloat(this,"PointRadius",
                0f,300f,100f)
        objectAnimator.duration=5000
        objectAnimator.start()
    }

    public fun setPointRadius(radius:Float){
        point=Point(radius)
        //不加下面一句，视图不会重写绘制
        invalidate()
    }
    public fun getPointRadius():Float{
        //当且仅当动画的只有一个过渡值时，系统才会调用对应属性的get函数来得到动画的初始值。
        return 50f
    }
}